-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: default open/openSync flags argument to 'r' #23767
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. What would the semver-iness of this be? minor?
doc/api/fs.md
Outdated
@@ -2318,7 +2318,8 @@ changes: | |||
--> | |||
|
|||
* `path` {string|Buffer|URL} | |||
* `flags` {string|number} See [support of file system `flags`][]. | |||
* `flags` {string|number} **Default:** `'r'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits:
- Missing period.
- One unneeded space in the next line indent alignment,
- It seems our common style is to place
**Default:**
notes at the end of a parameter description:
* `flags` {string|number} See [support of file system `flags`][].
**Default:** `'r'`.
doc/api/fs.md
Outdated
@@ -2351,7 +2352,8 @@ changes: | |||
--> | |||
|
|||
* `path` {string|Buffer|URL} | |||
* `flags` {string|number} See [support of file system `flags`][]. | |||
* `flags` {string|number} **Default:** `'r'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto:
* `flags` {string|number} See [support of file system `flags`][].
**Default:** `'r'`.
Should the |
doc/api/fs.md
Outdated
@@ -2304,7 +2304,7 @@ this API: [`fs.mkdtemp()`][]. | |||
The optional `options` argument can be a string specifying an encoding, or an | |||
object with an `encoding` property specifying the character encoding to use. | |||
|
|||
## fs.open(path, flags[, mode], callback) | |||
## fs.open(path[, flags, mode], callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## fs.open(path[, flags, mode], callback) | |
## fs.open(path[, flags[, mode]], callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a style we use elsewhere? It looks unfamiliar to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see https://nodejs.org/api/buffer.html#buffer_buf_fill_value_offset_end_encoding for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The [, flags[, mode]],
is the right doc convention, and looks to agree with how it is now implemented.
Make fs.open() and fs.openSync() more economic to use by making the flags argument optional. You can now write: fs.open(file, cb) Instead of the more verbose: fs.open(file, 'r', cb) This idiom is already supported by functions like fs.readFile().
38bfd21
to
43e6f91
Compare
Updated based on feedback:
|
Is this semver minor or major? i.e. could any existing code break? CI: |
Yes, minor. |
Test failure is #23807 and unrelated (wasn't fixed yet when the CI was started.) |
Last CI was green. Any reason this shouldn't land? |
I think this can land, my nit can be addressed in another PR if wanted. |
Applied the nit. |
Make fs.open() and fs.openSync() more economic to use by making the flags argument optional. You can now write: fs.open(file, cb) Instead of the more verbose: fs.open(file, 'r', cb) This idiom is already supported by functions like fs.readFile(). PR-URL: nodejs#23767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Landed in 482b56a |
Make fs.open() and fs.openSync() more economic to use by making the flags argument optional. You can now write: fs.open(file, cb) Instead of the more verbose: fs.open(file, 'r', cb) This idiom is already supported by functions like fs.readFile(). PR-URL: #23767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Make fs.open() and fs.openSync() more economic to use by making the flags argument optional. You can now write: fs.open(file, cb) Instead of the more verbose: fs.open(file, 'r', cb) This idiom is already supported by functions like fs.readFile(). PR-URL: #23767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Was missed on original PR. Ref: nodejs#23767
Was missed on original PR. Ref: nodejs#23767 PR-URL: nodejs#24240 Refs: nodejs#23767 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Was missed on original PR. Ref: nodejs#23767 PR-URL: nodejs#24240 Refs: nodejs#23767 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Make fs.open() and fs.openSync() more economic to use by making the flags argument optional. You can now write: fs.open(file, cb) Instead of the more verbose: fs.open(file, 'r', cb) This idiom is already supported by functions like fs.readFile(). PR-URL: #23767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Make fs.open() and fs.openSync() more economic to use by making the
flags argument optional. You can now write:
Instead of the more verbose:
This idiom is already supported by functions like fs.readFile().